/* 
  array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
*/
let a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
// reduce实现数组累加；reduceRight同理，从右到左相加
let sum = a.reduce((pre, cur) => {
  return pre + cur;
}, 0);
console.log("sum =", sum);
